package com.ccc.demoboot.common;

import com.alibaba.excel.util.ListUtils;

import java.util.*;

public class NoModelWriteExcel{

    public List<List<String>> head(List<Map<String,Object>> mapList) {
        List<List<String>> list = ListUtils.newArrayList();

        for (Map<String, Object> objectMap : mapList) {
            Iterator<String> iterator = objectMap.keySet().iterator();
            while (iterator.hasNext()) {
                List<String> head0 = ListUtils.newArrayList();
                head0.add(iterator.next());
                list.add(head0);
            }
            break;
        }
        return list;
    }

    public List<List<Object>> dataList(List<Map<String,Object>> mapList) {
        List<List<Object>> list = ListUtils.newArrayList();

        for (Map<String, Object> objectMap : mapList) {
            List<Object> data = ListUtils.newArrayList();
            Set<String> strings = objectMap.keySet();//键
            for (String string : strings) {
                data.add(objectMap.get(string)+"");
            }

            list.add(data);
        }

        return list;
    }

}


